#author: Elisabete - elisabetetn2004@gmail.com
#date: 2009/10/05
import sys
import os

try:
	#path
	dir = sys.argv[1].replace('\\','/')
        print "dir ",dir
        
	if os.path.exists(dir):
				
		#path dictionary
		docDir 		= os.listdir(dir)
                print "docDir ", docDir
                
		#files found
                total 		= len(docDir)
		print 'Found %s file(s).'%(total)

		for file in docDir:
			atual = os.path.join(dir,file)
			print "atual ",atual
                        atual = atual.replace('\\','/')
                        atual = '"'+atual+'"'
			try:
				#execute current PPS file
				os.system(atual)
			except Exception:
				#in case of not being a image or don't have permission.
				print 'Can\'t execute file ',atual
		else:
			print

		print 'Files execute are on '+dir
		
	else:
		print dir+' invalid dir! aborting...'

except IndexError:
	print 'Usage: python pyexePPS.py path/to/execute/'
